<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
function user_ins(){
    return new App\User;
};
function question_ins(){
    return new App\Question;
}
function rq($key=null,$defaule=null){
    if (!$key){
        return Request::all();
    }else{
        return Request::get($key,$defaule);
    }
}
/*路由模块，定义路由*/
Route::get('/', function () {
    return view('welcome');
});

Route::any('api', function () {
    return ['version' => 0.1];
});

/*注册路由*/
Route::any('api/signup', function () {
    return user_ins()->signup();
});

/*登录路由*/
Route::any('api/login',function ()
{
    return user_ins()->login();
});

/*登出路由*/
Route::any('api/loginout',function ()
{
    return user_ins()->loginout();
});

/*创建问题路由*/
Route::any('api/question/add',function ()
{
    return question_ins()->add();
});

/*更改问题路由*/
Route::any('api/question/change',function ()
{
    return question_ins()->change();
});

/*查看问题路由*/
Route::any('api/question/read',function ()
{
    return question_ins()->read();
});

/*删除问题路由*/
Route::any('api/question/remove',function ()
{
    return question_ins()->remove();
});




/*测试用户是否登录路由*/
Route::any('test',function ()
{
    dd(user_ins()->is_logged_in());
});